package jm.demo.reflection;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class ClassLoaderDemo {
	
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			URL[] urls = new URL[] { new URL("http://www.javacourses.com/classes/test.jar") };
			URLClassLoader loader = URLClassLoader.newInstance(urls);
			
			Class<?> loadClass = loader.loadClass("Tester");
			System.out.println(loadClass.newInstance().toString());
			loadClass = loader.loadClass("java.util.Date");
			System.out.println(loadClass.newInstance().toString());
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
